var h5PlanPort;

// 导航通信
window.addEventListener('message', function(event) {
    if (event.data == 'h5PlanPort') {
        if(event.ports[0] != null) {
            h5PlanPort = event.ports[0]; // 1. 保存从ets侧发送过来的端口
            h5PlanPort.onmessage = function(event) {
                var result = event.data;
                if (typeof(result) == "string") {
                    NaviBy(result.split("@"));
                }
                else if (typeof(result) == "object") {
                    if (result instanceof Array) {

                    } else {
                        console.log("not my type");
                    }
                }
                else {
                    console.log("not support type");
                }
            }
            h5PlanPort.onmessageerror = (event) => {
                console.error(`hwd In html Error receiving message: ${event}`);
            };
        }
    }
})

// function NaviBy1(){
//     NaviBy(["118.898855,31.911025","118.818246,31.931074","驾车", "南京"])
// }
//
// document.getElementById('but1').addEventListener('click', NaviBy1);